#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow( QWidget* parent ) : QMainWindow( parent ), ui( new Ui::MainWindow ) {
    ui->setupUi( this );
    QTimer* timer50ms = new QTimer();
    connect( timer50ms, SIGNAL( timeout() ), this, SLOT( slt50msTimer() ) );
    timer50ms->start( 50 );
}

MainWindow::~MainWindow() {
    delete ui;
}

void MainWindow::on_pushButton_clicked() {}
void MainWindow::slt50msTimer() {
    QDBusMessage message = QDBusMessage::createMethodCall( "com.lanhai.Server", "/com/ObjectPath/CTestDbus", "com.lanhai.CTestDbus", "testString" );

    message << QString( "value= %1" ).arg( i++ );
    QDBusMessage response = QDBusConnection::sessionBus().call( message );
    if ( response.type() == QDBusMessage::ReplyMessage ) {
        QString value = response.arguments().takeFirst().toString();
        qDebug() << QString( "Client get return value = %1 " ).arg( value );
    }
    else {
        qDebug() << "value mathod called failed ";
    }
}
